const Sequelize=require('sequelize');
const config=require('./config');

var sequelize=new Sequelize(config.database,config.username,config.password,{
	host:config.host,
	dialect:'mysql',
	pool:{
		max:5,
		min:0,
		idle:30000
	}
})

var Pet = sequelize.define('pet',{
	id:{
		type:Sequelize.STRING(50),
		primaryKey:true
	},
	name:Sequelize.STRING(100),
	gender:Sequelize.BOOLEAN,
	birth:Sequelize.STRING(10),
	createdAt:Sequelize.BIGINT,
	updateAT:Sequelize.BIGINT,
	version:Sequelize.BIGINT
},{
	timestamps:false
})

var now =Date.now();
Pet.create({
	id:'g-' + now,
	name:'Gaffey',
	birth:'2007-07-07',
	cratedAt:now,
	updateAt:now,
	verson:0
}).then(function(p){
	console.log('create.'+JSON.stringify(p))
}).catch(function(err){
	console.log('faile:'+err)
})
